﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MapViewer.Model
{
	public abstract class RecentItem
	{
		public static RecentItem Parse(String recentDefinition)
		{
			RecentItem item = null;
			int splitIndex = recentDefinition.IndexOf(':');
			string typeName = recentDefinition.Substring(0, splitIndex);
			string value = recentDefinition.Substring(splitIndex + 1);
			Type t = Type.GetType(typeName);
			if (t != null)
			{
				item = t.GetConstructor(Type.EmptyTypes).Invoke(null) as RecentItem;
				item.ParseValue(value);
			}
			return item;
		}

		public virtual String Definition { get { return GetType().AssemblyQualifiedName + ":"; } }
		public abstract String Title { get; }
		internal abstract void ParseValue(String definition);
	}
}
